package com.fcl.blog.comment;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.security.PrivateKey;

/**
 * @Author 付
 * @Date 2023/10/18 15:35
 * @Version 1.0
 * @description
 * @since 1.0
 */
@Data
@AllArgsConstructor
@NoArgsConstructor

public class Result {
    private String code;
    private Object data;
    private String msg;
    private static final String  ERROR_CODE="400";
    private static final String  SUCCESS_CODE="200";


    public static Result success(Object data){
        Result result=new Result();
        result.setCode(SUCCESS_CODE);
        result.setMsg("获取成功");
        result.setData(data);

        return result;
    }
    public static Result success(String msg,Object data){
        Result result=new Result();
        result.setCode(SUCCESS_CODE);
        result.setMsg("获取成功");
        result.setData(data);

        return result;
    }
    public static Result success(String msg){
        Result result = new Result();
        result.setCode(SUCCESS_CODE);
        result.setMsg(msg);
        return result;
    }

    public static Result error(String msg,Exception e){
        Result result = new Result();
        result.setMsg(msg+"-->"+"e");
        result.setCode(ERROR_CODE);
        return result;
    }

    public static Result error(String msg){
        Result result = new Result();
        result.setMsg(msg);
        result.setCode(ERROR_CODE);
        return result;
    }

    public static Result error(String msg,String code){
        Result result = new Result();
        result.setMsg(msg);
        result.setCode(code);
        return result;
    }


}
